@import '../../styles/colors.scss';
@import '../../styles/spacing.scss';
@import '../../styles/typography.scss';
@import '../../styles/opacity.scss';
@import '../../styles/variables.scss';

$baseClass: 'vant-button';

button.#{$baseClass},
a.#{$baseClass} {
  @include normal;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  position: relative;
  color: $dark-text;
  background-color: $default;
  padding: 0 $padding-sm;
  border-width: 1px;
  border-style: solid;
  border-color: transparent;
  height: $button-height;
  border-radius: 2px;
  cursor: pointer;
  transition: opacity 0.2s;
  outline: none;
  text-decoration: none;

  &::before {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    background-color: $black;
    border: inherit;
    border-color: $black;
    border-radius: inherit; /* inherit parent's border radius */
    transform: translate(-50%, -50%);
    opacity: 0;
    content: ' ';
  }
  &:first-child {
    i {
      margin: 0px;
    }
  }

  &:active {
    &::before {
      opacity: 0.1;
    }
  }

  &__default {
    background-color: $default;
    border-color: $grey-text;
    color: $dark-text;
  }

  &__primary {
    background-color: $primary;
    border-color: $primary;
    color: $light-text;
  }
  &__info {
    background-color: $info;
    border-color: $info;
    color: $light-text;
  }
  &__danger {
    background-color: $danger;
    border-color: $danger;
    color: $light-text;
  }
  &__warning {
    background-color: $warning;
    border-color: $warning;
    color: $light-text;
  }

  &__plain {
    background-color: $default;
    &.#{$baseClass}__primary {
      color: $primary;
    }
    &.#{$baseClass}__info {
      color: $info;
    }
    &.#{$baseClass}__danger {
      color: $danger;
    }
    &.#{$baseClass}__warning {
      color: $warning;
    }
  }

  &__hairline {
    border-width: 0.5px;
    padding: 0.5px $padding-sm + 0.5px;
  }

  &__square {
    border-radius: 0;
  }
  &__round {
    border-radius: $button-height / 2;
  }

  &__block {
    display: flex;
    width: 100%;
  }

  &__loading {
    cursor: not-allowed;

    span {
      margin-left: 5px;
    }
  }

  &__loading,
  &__disabled {
    &::before {
      display: none;
    }
  }

  &__disabled {
    cursor: not-allowed;
    opacity: $button-disabled-opacity;
  }

  &__large {
    height: 50px;
    font-size: 16px;
  }

  &__small {
    height: 30px;
    font-size: 12px;
    font-weight: 300;
    padding: 0 $space-md;
  }

  &__mini {
    height: 22px;
    font-size: 10px;
    padding: 0 $space-sm;
  }

  img {
    height: $loader-size;
    width: $loader-size;
    object-fit: cover;
    object-position: 50% 50%;
    margin-right: 5px;
  }

  .vant-icon__container {
    margin-right: 5px;
  }

  &__onlyIcon {
    .vant-icon__container {
      margin-right: 0px;
    }
  }
}
